//package com.dc.common.aop;
//
//import java.text.ParseException;
//import java.util.Date;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpSession;
//
//import org.aspectj.lang.JoinPoint;
//import org.aspectj.lang.annotation.After;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Pointcut;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//
//import com.dc.base.util.DateUtil;
//import com.dc.common.constants.ConstantsCommon;
//import com.dc.common.model.BaseModel;
//import com.dc.system.model.SystemLoginLog;
//import com.dc.system.model.SystemOperationLog;
//import com.dc.system.model.SystemUser;
//import com.dc.system.service.SysOperationLogService;
///**
// * 日志记录切面
// * @author Shen
// * @date 2018年4月10日 下午1:26:29
// */
//@Component
//@Aspect
//public class LogOperationAspect {
//
//	// 日志记录对象
//	private static final Logger logger = LoggerFactory.getLogger(LogOperationAspect.class);
//
//	@Autowired
//	private SysOperationLogService sysOperationLogService;
//
//	@Pointcut("@annotation(com.dc.common.aop.LogAop)")
//	public void controllerAspect() {
//	}
//
//	@After("controllerAspect() && @annotation(data)")
//	public void doAfter(JoinPoint point, LogAop data) {
//		// 获取request
//		HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
//				.getRequest();
//		HttpSession session = request.getSession();
//
//		// 获取baseModel
//		BaseModel baseModel = new BaseModel();
//		if (point.getArgs() != null) {
//			for (Object obj : point.getArgs()) {
//				if (obj.getClass() == BaseModel.class) {
//					baseModel = (BaseModel) obj;
//					break;
//				}
//			}
//		}
//
//		// 放入操作日志
//		SystemOperationLog systemOperationLog = new SystemOperationLog();
//		SystemUser systemUser = (SystemUser) session.getAttribute(ConstantsCommon.LOGIN_USERINFO);
//		systemOperationLog.setOperation_content(baseModel.getAopMsg());
//		if(systemUser!=null){
//			systemOperationLog.setOperation_user_id(systemUser.getUser_id());
//			systemOperationLog.setOperation_user_name(systemUser.getUser_name());
//			systemOperationLog.setOperation_user_account(systemUser.getUser_account());
//		}else{
//			systemOperationLog.setOperation_content("无登陆用户，请检查是否是接口调试，还是被恶意调用");
//		}
//		
//		try {
//			systemOperationLog.setOperation_date(DateUtil.formatDate(new Date()));
//		} catch (ParseException e1) {
//			logger.error("操作日志时间转换出错", e1);
//		}
//		
//		systemOperationLog.setOperation_type(data.type());
//		systemOperationLog.setOperation_module(data.module().getModule());
//		systemOperationLog.setRequest_ip(request.getRemoteAddr());
//		// sysOperationLog.setRequestParams();//请求参数可能太多，暂时不保存
//		systemOperationLog.setRequest_method(point.getTarget().getClass().getName() + "." + point.getSignature().getName() + "()");
//
//		try {
//			sysOperationLogService.insertOperationLog(systemOperationLog);
//		} catch (Exception e) {
//			logger.error("操作日志插入数据库失败", e);
//		}
//
//	}
//
//}
